package main;

import java.util.HashMap;
import java.util.Map;

public class LeetCode12 {
    static Map<Integer, String> map = new HashMap<>();

    static {
        map.put(1, "I");
        map.put(5, "V");
        map.put(10, "X");
        map.put(50, "L");
        map.put(100, "C");
        map.put(500, "D");
        map.put(1000, "M");
    }

    public String IntToRoma(int num) {
        StringBuilder sb = new StringBuilder();
        int[] arr = new int[4];
        int tmp = num;
        int base = 1000;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = tmp / base;
            tmp = tmp - arr[i] * base;
            base = base / 10;
        }
        base = 10000;
        for (int i = 0; i < arr.length; i++) {
            base = base / 10;
            int tmp1 = arr[i];
            if (tmp1 == 0)
                continue;
            if (tmp1 % 5 == 4) {
                sb.append(getStr(base, 1));
                String s = (tmp1 / 5 != 0) ? getStr(base * 10, 1) : getStr(base * 5, 1);
                sb.append(s);
            } else {
                if (tmp1 > 5) {
                    sb.append(getStr(base * 5, 1));
                    sb.append(getStr(base, tmp1 - 5));
                } else {
                    sb.append((tmp1 == 5) ? getStr(base * 5, 1) : getStr(base, tmp1));
                }
            }
        }

        return sb.toString();
    }

    private String getStr(int base, int time) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < time; i++) {
            sb.append(map.get(base));
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(9 % 5);

    }
}
